<template>
  <div id="myChart" style="width: 500px; height: 500px"></div>
</template>

<script>
export default {
  name: "Echarts",

  data() {
    return {};
  },

  mounted() {
    this.drawBar();
  },

  methods: {
    drawBar() {
      let myChart = this.$echarts.init(document.getElementById("myChart"));
      let option = {
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [120, 200, 150, 80, 70, 110, 130],
            type: "bar",
            showBackground: true,
            backgroundStyle: {
              color: "rgba(180, 180, 180, 0.2)",
            },
          },
        ],
      };
      myChart.setOption(option);
      window.addEventListener("resize", () => {
        setTimeout(() => {
          myChart.resize();
        }, 200);
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
